package com.bitdf.txing.group.feign.impl.order;

import com.bitdf.txing.order.feign.OrderUserFeignService;
import com.bitdf.txing.order.vo.UserAddressVo;
import com.bitdf.txing.users.entity.UserReceiveAddressEntity;
import com.bitdf.txing.users.service.UserReceiveAddressService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Lizhiwei
 * @date 2023/9/5 23:31:20
 * 注释：
 */
@Service
@ConditionalOnProperty(value = "tx.deploy.mode", havingValue = "standalone")
public class OrderUserFeignServiceImpl implements OrderUserFeignService {
    @Autowired
    UserReceiveAddressService userReceiveAddressService;
    @Override
    public List<UserAddressVo> getAddress(Long memberId) {
        List<UserReceiveAddressEntity> list = userReceiveAddressService.getAddress(memberId);
        List<UserAddressVo> collect = list.stream().map(item -> {
            UserAddressVo addressVo = new UserAddressVo();
            BeanUtils.copyProperties(item, addressVo);
            return addressVo;
        }).collect(Collectors.toList());
        return collect;
    }
}
